<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    // 使用reduce实现数组去重
    let arr = [1, 3, 5, 7, 9, 1, 3, 5]
    let res = arr.reduce(function (pre, cur) {
      return (pre.indexOf(cur) === -1) ? pre.concat(cur) : pre
    }, [])
    console.log(res); //[1, 3, 5, 7, 9]
  </script>
</body>

</html>